package com.atguigu.gmall.product.rpc;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.service.BaseCategory1Service;
import com.atguigu.gmall.product.vo.CategoryTreeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author lfy
 * @Description  凡是 以： /api/inner 开头的都是内部的rpc接口
 * 规范： /api/inner/微服务/功能路径
 * @create 2023-07-15 9:36
 */
@RequestMapping("/api/inner/product")
@RestController
public class CategoryRpcController {


    @Autowired
    BaseCategory1Service category1Service;

    /**
     * 获取所有三级分类数据，并组装树形结构
     * @return
     */
    @GetMapping("/category/tree")
    public Result getCategoryTree(){

        //树形数据查询
        List<CategoryTreeVo> categoryTreeVos = category1Service.getCategoryTree();

        return Result.ok(categoryTreeVos);
    }
}
